package com.kuang.service;

import com.kuang.dao.UuserMapper;
import com.kuang.pojo.Uuser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class UuserServiceImpl implements UuserService {

    //service 调用 dao
    @Autowired
    private com.kuang.dao.UuserMapper UuserMapper;

    public void setUuserMapper(com.kuang.dao.UuserMapper uuserMapper) {
        UuserMapper = uuserMapper;
    }
    //用户登录
    public Uuser Login(Uuser Uuser) {
        HashMap<String,Object> map = new HashMap<String,Object>();
        System.out.println("Uuser.getUNAME();"+  Uuser.getUNAME()+
                " Uuser.getPWD():"+Uuser.getPWD());
        map.put("v_uname", Uuser.getUNAME());
        map.put("v_pwd", Uuser.getPWD());
        UuserMapper.Login(map);
        List<Uuser> uusers=(List<Uuser>)map.get("v_cursor");
        if(uusers==null)return null;
        return uusers.get(0);
    }

    public void addUser(Uuser Uuser) {
        HashMap<String,Object> map = new HashMap<String,Object>();
        map.put("v_rname", Uuser.getRNAME());
        map.put("v_uname", Uuser.getUNAME());
        map.put("v_pwd", Uuser.getPWD());
        System.out.println("addUser=>"+Uuser.toString());
        UuserMapper.addUser(map);
    }

    public int isOne(String UNAME) {
        return UuserMapper.isOne(UNAME);
    }
}
